<template>
  <el-dialog :title="dTitle" :visible.sync="visible" width="50%" :before-close="closeDialog">
    <el-form :rules="rules" :model="form" ref="form" class="form-style form" label-width="100px">
      <el-form-item label="客户名称:" prop="atName">
        <el-input v-model="form.atName" placeholder="请输入客服名称"></el-input>
      </el-form-item>
      <el-form-item label="手机号:" prop="atPhone">
        <el-input placeholder="请输入手机等" v-model="form.atPhone"></el-input>
      </el-form-item>
      <el-form-item>
          <el-button>保存</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
import { AddSupplier, LoadSuppliers } from "@/request/api";
export default {
  props: {
    dTitle: {
      type: String,
      default: "",
    },
    visible: {
      type: Boolean,
      default: false,
    },
    formData: {
      type: Object,
      default: {},
    },
  },
  methods: {
    closeDialog(reload) {
      this.$emit("closeDialog", reload);
    },
  },
  watch: {
    formData(newVal, oldVal) {
      if (newVal) {
        this.form = { ...newVal };
      }
    },
  },
  mounted() {
    this.$nextTick(function () {
      this.form = this.formData;
    });
  },
  data() {
    return {
      form: {},
      options: [],
      rules: {
        atName: [
          { required: true, message: "名称不能为空", trigger: "blur" }
        ],
        atPhone: [
          { required: true, message: "请输入联络方式", trigger: "blur" },
        ]
      },
    };
  },
};
</script>

<style lang="less" scoped>
.form {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;

.el-form-item {
  width: 80%;
}
}
</style>